#include <stdio.h>
#include <unistd.h>


int main(int argc,char const argv[]){

    char buf[64*1024]="";
    int fd[2]={0};
    if(pipe(fd) < 0){
        perror("pipe err");
        return -1;
    }

    printf("%d,%d\n",fd[0],fd[1]);

    write(fd[1],"hellow",5);
    read(fd[0],buf,32);
    printf("buf:%s\n",buf);

    //管道空，读阻塞
    // read(fd[0],buf,32);
    // printf("buf:%s\n",buf);

    //管道满，写阻塞
    write(fd[1],buf,sizeof(buf));
    printf("write full\n");
    // write(fd[1],buf,sizeof(buf));
    // printf("write after\n");


    read(fd[0],buf,4096);
    write(fd[1],"ab",2);
    printf("write aa\n");

    close(fd[0]);
    write(fd[1],"ab",2);
    printf("read close\n");


    return 0;
}